<!DOCTYPE html>
<html>
<head>
<script>
function validatePassword()
{
if((document.getElementById("txtPassword").value).length<8)
{
alert("password length should be atleast 8");
}
if((((document.getElementById("txtPassword").value).indexOf('@'))!=-1)||(((document.getElementById("txtPassword").value).indexOf('!'))!=-1)||(((document.getElementById("txtPassword").value).indexOf('#'))!=-1)||(((document.getElementById("txtPassword").value).indexOf('$'))!=-1)||(((document.getElementById("txtPassword").value).indexOf('%'))!=-1)||(((document.getElementById("txtPassword").value).indexOf('^'))!=-1)||(((document.getElementById("txtPassword").value).indexOf('&'))!=-1)||(((document.getElementById("txtPassword").value).indexOf('*'))!=-1))
{
alert("");
}
else
{
alert("password should contain atleast one special character");
}
}

</script>
</head>
<body>

Password: <input type="password" name="password" id="txtPassword" onblur="validatePassword()">

</body>
</html>
